<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $request_url = $_SERVER['REQUEST_URI'];
        $argu = I('get.');
        $info_id = $argu['login_id'] ? $argu['login_id'] : 0;
        if($info_id){
            $info_res = $this->get_info($info_id);
            if($info_res){
                $url = $info_res['url'];
                $url .= preg_replace("/^.*({$info_res['goid']}\/)/",'/',$request_url);
                M('login_log')->add(array(
                    'i_id'=>$info_res['id'],
                    'time' => time(),
                ));
                header('Location: '.$url);
            }
        }

    }

    /**
     * 获得授权id的信息
     */
    protected function get_info($id){
        $info_res = M('login_info')->where(array(
            'status' => 1,
            'is_delete'=> 0,
            'goid' => $id,
        ))->find();
        return $info_res;
    }
}